<?php

$page = 'admin';
include_once 'header.php';

require_once '../actions/online_functions.php';

if (isset($_GET['message'])) {
    extract($_GET);
    addNotification($message, "Admin", $staff_id);
    header("location: ?");
}
?>
<script>
    function sendMessage(staff_id){
        message=prompt("Enter the message");
        if(message.length>0){
            location="?message="+message+"&staff_id="+staff_id;
        }
    }
</script>
<h2>
    Staff
</h2>
<p> Registered users</p>
<?php

$query = "SELECT * FROM students_login order by username";
$result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
echo "<table style='border:5px;border-style:solid;width: 100%;'>";
echo "<tr style='background-color:#ccccff;text-transform:capitalize'>";
echo "<th></th><th>Phone no</th><th>Username</th><th>Courses</th><th>Message</th></tr>";
$count = 0;
while ($row = mysql_fetch_assoc($result)) {
    extract($row);
    $count++;
    $styl = $count % 2 ? "background-color:#eeefff;" : "background-color:#deefff;";
    $courses = "staff_courses.php?staff_id=";
    echo "<tr style='$styl'><td>$count</td><td>$phone_number</td><td>$username</td><td><a href='$courses$id'>View</a></td><td><a href='javascript:sendMessage($id)'>Send</a></td></tr>";
}
echo "</table>";
?>


<?php include_once 'footer.php'; ?>